package com.billing.web.controller.attendance;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.billing.model.entity.TClocktime;
import com.billing.model.entity.TDept;
import com.billing.model.entity.TScheduling;
import com.billing.model.entity.TSchedulingdetails;
import com.billing.model.entity.TShift;
import com.billing.model.entity.TShiftPunchtime;
import com.billing.model.entity.TUser;
import com.billing.service.ClocktimeService;
import com.billing.service.DeptService;
import com.billing.service.SchedulingService;
import com.billing.service.SchedulingdetailsService;
import com.billing.service.ShiftPunchtimeService;
import com.billing.service.ShiftService;
import com.billing.service.UserService;
import com.billing.utils.DateUtil;

/**
 * 排班信息
 * @author Administrator
 *
 */
@RequestMapping(value="/shift")
@Controller
public class ShiftController {

	@Resource
	private ShiftService shiftService;
	@Resource
	private ShiftPunchtimeService shiftPunchtimeService;
	@Resource
	private SchedulingService schedulingService;
	@Resource
	private SchedulingdetailsService schedulingdetailsService;
	@Resource
	private ClocktimeService clocktimeService;
	@Resource
	private UserService userService;
	@Resource
	private DeptService deptService;
	
	/**
	 * 获取班次列表信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(HttpServletRequest request, Model model){
		int pageSize = 10;
		// 获取当前页数
		int currentPage = 1;
		try {
			currentPage = new Integer(request.getParameter("currentPage"));
		} catch (Exception e) {
		}
		currentPage = currentPage <= 0 ? 1 : currentPage;
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		int totalNum = shiftService.selectTShiftNum(organizationid);
		int totalPage = totalNum / pageSize;
		if (totalNum % pageSize != 0) {
			totalPage++;
		}
		totalPage = totalPage <= 0 ? 1 : totalPage;
		currentPage = currentPage > totalPage ? totalPage : currentPage;
		List<TShift> list=shiftService.selectTShiftList(organizationid,(currentPage - 1) * pageSize, pageSize);
		request.setAttribute("currentPage", currentPage);
        request.setAttribute("totalNum", totalNum);
        request.setAttribute("totalPage", totalPage);
		request.setAttribute("list", list);
		return "attendance/shiftindex";
	}
	
	/**
	 * 新增班次信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/insertShift",method=RequestMethod.GET)
	public String insertShift(HttpServletRequest request, Model model){
		return "attendance/insertShift";
	}
	
	/**
	 * 新增班次信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/insert",method=RequestMethod.POST)
	public String insert(HttpServletRequest request, Model model){
		String tiems = request.getParameter("tiems");
		String name = request.getParameter("name");
		String colour = request.getParameter("colour");
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		TShift sh=new TShift();
		List<TShiftPunchtime> list=new ArrayList<TShiftPunchtime>();
		TShiftPunchtime sp=null;
		sh.setName(name);
		sh.setType(2);
		sh.setStartduration("120");
		sh.setEndduration("120");
		sh.setColour(colour);
		sh.setOrganizationId(organizationid);
		int fal=shiftService.insertTShift(sh);
		if(fal>0){
			if(tiems.lastIndexOf(";")>0){
				String[] tiem=tiems.split(";");
				for (int i = 0; i < tiem.length; i++) {
					sp=new TShiftPunchtime();
					if(tiem[i].lastIndexOf(",")>0){
						sp.setStarttime(tiem[i].substring(0,tiem[i].lastIndexOf(",")));
						sp.setEndtime(tiem[i].substring(tiem[i].lastIndexOf(",")+1,tiem[i].length()));
						sp.setShiftId(sh.getId());
						list.add(sp);
					}
				}
			}
			if(list.size()>0){
				shiftPunchtimeService.insertTShiftPunchtimeList(list);
			}
			request.setAttribute("msg", "新增班次成功!");
		}else{
			request.setAttribute("msg", "新增班次失败!");
		}
		return "attendance/insertShift";
	}
	
	/**
	 * 修改班次信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/updateShift",method=RequestMethod.GET)
	public String updateShift(HttpServletRequest request, Model model){
		String id = request.getParameter("id");
		TShift shift=shiftService.getTShift(Integer.valueOf(id));
		request.setAttribute("shift", shift);
		request.setAttribute("spnum", shift.getSplist().size());
		return "attendance/updateShift";
	}
	
	/**
	 * 修改班次信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/update",method=RequestMethod.POST)
	public String update(HttpServletRequest request, Model model){
		String id = request.getParameter("id");
		TShift shift=shiftService.getTShift(Integer.valueOf(id));
		String tiems = request.getParameter("tiems");
		String name = request.getParameter("name");
		String colour = request.getParameter("colour");
		List<TShiftPunchtime> list=new ArrayList<TShiftPunchtime>();//保存页面提交的时间
		List<TShiftPunchtime> spold=new ArrayList<TShiftPunchtime>();
		if(shift.getSplist()!=null&&shift.getSplist().size()>0){
			spold.addAll(shift.getSplist());
		}
		TShiftPunchtime old=null;
		TShiftPunchtime sp=null;
		shift.setName(name);
		shift.setStartduration("120");
		shift.setEndduration("120");
		shift.setColour(colour);
		if(tiems.lastIndexOf(";")>0){
			String[] tiem=tiems.split(";");
			for (int i = 0; i < tiem.length; i++) {
				if(tiem[i].lastIndexOf(",")>0){
					String[] punchtime=tiem[i].split(",");
					if(punchtime.length >= 3){
						sp=new TShiftPunchtime();
						if(!punchtime[0].equals("")){
							sp.setId(Integer.valueOf(punchtime[0].toString()));
						}else{
							sp.setId(0);
						}
						sp.setStarttime(punchtime[1].toString());
						sp.setEndtime(punchtime[2].toString());
						sp.setShiftId(shift.getId());
						if(sp.getId()==0){
							list.add(sp);
						}else{
							for (TShiftPunchtime splist : shift.getSplist()) {
								if(splist.getId()==sp.getId()){
									splist.setStarttime(sp.getStarttime());
									splist.setEndtime(sp.getEndtime());
									continue;
								}
							}
							old=new TShiftPunchtime();
							for (TShiftPunchtime splist : spold) {
								if(splist.getId()==sp.getId()){
									old=splist;
									continue;
								}
							}
							if(old.getId()!=null){
								spold.remove(old);
							}
						}
					}
				}
			}
		}
		if(list.size()>0){
			shiftPunchtimeService.insertTShiftPunchtimeList(list);
		}
		if(spold.size()>0){
			List<Integer> ids=new ArrayList<Integer>();
			for (TShiftPunchtime  rem: spold) {
				ids.add(rem.getId());
			}
			shiftPunchtimeService.deleteTShiftPunchtime(ids);
		}
		if(shift!=null){
			shiftService.updateTShift(shift);
			for (TShiftPunchtime punchtime : shift.getSplist()) {
				shiftPunchtimeService.updateTShiftPunchtime(punchtime);
			}
		}
		request.setAttribute("msg", "修改班次成功!");
		request.setAttribute("shift", shift);
		request.setAttribute("spnum", shift.getSplist().size());
		return "attendance/updateShift";
	}
	
	
	/**
	 * 删除班次信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/deleteShift",method=RequestMethod.POST)
	public String deleteShift(HttpServletRequest request, Model model){
		String id = request.getParameter("id");
		if(id!=null&&id!=""){
			shiftService.deleteTShift(Integer.valueOf(id));
			shiftPunchtimeService.deleteTShiftPunchtimeShiftId(Integer.valueOf(id));
		}
		return index(request, model);
	}
	
	/**
	 * 生成排班日期信息
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException 
	 */
	@RequestMapping(value="/generateScheduling",method=RequestMethod.GET)
	public String generateScheduling(HttpServletRequest request, Model model) throws ParseException{
		String id = request.getParameter("id");
		TShift shift=shiftService.getTShift(Integer.valueOf(id));
		long time=System.currentTimeMillis();
		int year=DateUtil.getYear(time);
		List<TSchedulingdetails>  tailist=schedulingdetailsService.getTSchedulingdetailsYear(year, shift.getId());
		String day="";
		int i=0;
		for (TSchedulingdetails tai : tailist) {
			i++;
			day+="'"+tai.getMonth()+"-"+tai.getDay()+"'";
			if(i<tailist.size()){
				day+=",";
			}
		}
		request.setAttribute("shift", shift);
		request.setAttribute("day", day);
		return "attendance/insertgenerateScheduling";
	}
	
	/**
	 * 根据年份和班次id获取考勤信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="generateSchedulingYear",method = RequestMethod.GET)
	@ResponseBody
	public String getLinkmanByCustId(HttpServletRequest request,Model model){
		String year = request.getParameter("year");
		String shiftid = request.getParameter("shiftid");
		List<TSchedulingdetails>  tailist=schedulingdetailsService.getTSchedulingdetailsYear(Integer.valueOf(year), Integer.valueOf(shiftid));
		Map<String, Object> map = new HashMap<>();
		String day="";
		int i=0;
		for (TSchedulingdetails tai : tailist) {
			i++;
			day+="'"+tai.getMonth()+"-"+tai.getDay()+"'";
			if(i<tailist.size()){
				day+=",";
			}
		}
		map.put("data", day);
		JSONObject object = JSONObject.fromObject(map);
		return object.toString();
	}
	
	
	
	/**
	 * 生成排班日期信息
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException 
	 */
	@RequestMapping(value="/generate",method=RequestMethod.POST)
	public String generate(HttpServletRequest request, Model model) throws ParseException{
		String id=request.getParameter("scheid");
		String time=request.getParameter("time");
		String year=request.getParameter("year");
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		if(time==null&&"".equals(time)){
			request.setAttribute("msg", "生成日期不能为空!");
			return generateScheduling(request, model);
		}
		if(time.lastIndexOf("-")<=-1){
			request.setAttribute("msg", "生成日期格式有误!");
			return generateScheduling(request, model);
		}
		TScheduling sche=schedulingService.selectTSchedulingByid(Integer.valueOf(id));
		List<TShift> shift=shiftService.selectTShiftList(organizationid,0, 999);
		if(sche!=null){
			clocktimeService.deleteTClocktime(Integer.valueOf(id), Integer.valueOf(year));
			schedulingdetailsService.deleteTSchedulingdetails(Integer.valueOf(id), Integer.valueOf(year));
			insertScheduling(time, sche, Integer.valueOf(year), shift);
			request.setAttribute("msg", "排班日期生成成功!");
		}else{
			sche=new TScheduling();
			sche.setShiftId(Integer.valueOf(id));
			sche.setCreatetime(System.currentTimeMillis());
			sche.setName("新增排班");
			sche.setOrganizationId(organizationid);
			schedulingService.insertTScheduling(sche);
			if(shift==null){
				request.setAttribute("msg", "获取不到班次信息!");
				return generateScheduling(request, model);
			}
			insertScheduling(time, sche, Integer.valueOf(year),shift);
			request.setAttribute("msg", "排班日期生成成功!");
		}
		return "attendance/insertgenerateScheduling";
	}
	
	/**
	 * 写入打卡时间
	 * @param time 日期时间集
	 * @param sche 排班
	 * @param year 年份
	 * @param shift 班次
	 * @throws ParseException
	 */
	public void insertScheduling(String time,TScheduling sche,int year,List<TShift> shiftlist) throws ParseException{
		List<TSchedulingdetails> newlist=new ArrayList<TSchedulingdetails>();
		TSchedulingdetails ls=null;
		String[] times=time.split(",");
		for (int i = 0; i < times.length; i++) {
			String[] date=times[i].split("-");
            ls=new TSchedulingdetails();
            ls.setSchedulingId(sche.getId());
            ls.setYear(Integer.valueOf(date[0].toString()));
            ls.setMonth(Integer.valueOf(date[1].toString()));
            ls.setDay(Integer.valueOf(date[2].toString()));
            ls.setShiftId(Integer.valueOf(date[3].toString()));
            newlist.add(ls);
		}
        schedulingdetailsService.insertTSchedulingdetailsList(newlist);
        List<TSchedulingdetails> lslist=schedulingdetailsService.getTSchedulingdetailsList(year, 0, 0,sche.getId());
        List<TClocktime> clolist=new ArrayList<TClocktime>();
        TClocktime clo=null;
        for (TSchedulingdetails orls : lslist) {
        	String starttime=orls.getYear()+"-"+orls.getMonth()+"-"+orls.getDay();
        	String endtime=orls.getYear()+"-"+orls.getMonth()+"-"+orls.getDay();
        	String start=null;
        	String end=null;
        	int i=0;
        	for (TShift shift : shiftlist) {
				if(shift.getId()==orls.getShiftId()){
					for (TShiftPunchtime sp : shift.getSplist()) {
						i++;
						clo=new TClocktime();
						start=starttime;
						start+=" "+sp.getStarttime();
						clo.setDetailsId(orls.getId());
						clo.setTime(DateUtil.getStringTime(start,"yyyy-MM-dd HH:mm"));
						clo.setSort(i);
						clolist.add(clo);
						i++;
						clo=new TClocktime();
						end=endtime;
						end+=" "+sp.getEndtime();
						clo.setDetailsId(orls.getId());
						clo.setTime(DateUtil.getStringTime(end,"yyyy-MM-dd HH:mm"));
						clo.setSort(i);
						clolist.add(clo);
					}
				}
			}
		}
        clocktimeService.insertTClocktimeList(clolist);
	}
	
	/**
	 * 获取用户信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/userindex",method=RequestMethod.GET)
	public String userindex(HttpServletRequest request, Model model){
		String name = request.getParameter("name");
		String dept = request.getParameter("dept");
		String jobnumber = request.getParameter("jobnumber");
		int pageSize = 10;
		try {
			if (dept!=null&&dept.length() > 0) {
				dept = URLDecoder.decode(URLDecoder.decode(dept, "UTF-8"),"UTF-8");
			}
			if (name!=null&&name.length() > 0) {
				name = URLDecoder.decode(URLDecoder.decode(name, "UTF-8"),"UTF-8");
			}
		} catch (UnsupportedEncodingException e) {
		}
		List<TDept> deptlist=deptService.getTDeptlist();
		request.setAttribute("name", name);
		request.setAttribute("dept", dept);
		request.setAttribute("jobnumber", jobnumber);
		request.setAttribute("deptlist", deptlist);
		Long starttime = 0l;
		Long endtime = 0l;
		// 获取当前页数
		int currentPage = 1;
		try {
			currentPage = new Integer(request.getParameter("currentPage"));
		} catch (Exception e) {
		}
		currentPage = currentPage <= 0 ? 1 : currentPage;
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		int totalNum = userService.selectTUserNum(name, dept, starttime, endtime, jobnumber,organizationid);
		int totalPage = totalNum / pageSize;
		if (totalNum % pageSize != 0) {
			totalPage++;	
		}
		totalPage = totalPage <= 0 ? 1 : totalPage;
		currentPage = currentPage > totalPage ? totalPage : currentPage;
		List<TUser> list=userService.selectTUserList(name, dept, starttime, endtime,jobnumber,organizationid, (currentPage - 1) * pageSize, pageSize);
		request.setAttribute("totalNum", totalNum);
		request.setAttribute("list", list);
		request.setAttribute("currentPage", currentPage);
        request.setAttribute("totalNum", totalNum);
        request.setAttribute("totalPage", totalPage);
		return "attendance/userindex";
	}
	
	/**
	 * 排班设置
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/insertUser",method=RequestMethod.GET)
	public String insertUser(HttpServletRequest request, Model model){
		String id=request.getParameter("id");
		TUser user=userService.selectTUserPayId(id);
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		List<TScheduling> list=schedulingService.selectTSchedulingList(organizationid,0, 999);
		request.setAttribute("user", user);
		request.setAttribute("list", list);
		return "attendance/insertuser";
	}
	
	/**
	 * 用户绑定排班
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException 
	 */
	@RequestMapping(value="/bindingUser",method=RequestMethod.POST)
	public String bindingUser(HttpServletRequest request, Model model) throws ParseException{
		String userid=request.getParameter("userid");
		String shiftid=request.getParameter("shiftid");
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		TUser user=userService.selectTUserPayId(userid);
		if(user==null){
			request.setAttribute("msg", "获取员工信息有误!");
			return "attendance/insertgenerateScheduling";
		}
		user.setSchedulingId(Integer.valueOf(shiftid));
		userService.updateTUser(user);
		List<TScheduling> list=schedulingService.selectTSchedulingList(organizationid,0, 999);
		user=userService.selectTUserPayId(userid);
		request.setAttribute("msg", "员工排班成功!");
		request.setAttribute("user", user);
		request.setAttribute("list", list);
		return "attendance/insertuser";
	}
	
	
	/**
	 * 获取排班列表信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/indexScheduling",method=RequestMethod.GET)
	public String indexScheduling(HttpServletRequest request, Model model){
		int pageSize = 10;
		// 获取当前页数
		int currentPage = 1;
		try {
			currentPage = new Integer(request.getParameter("currentPage"));
		} catch (Exception e) {
		}
		currentPage = currentPage <= 0 ? 1 : currentPage;
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		int totalNum = schedulingService.selectTSchedulingNum(organizationid);
		int totalPage = totalNum / pageSize;
		if (totalNum % pageSize != 0) {
			totalPage++;
		}
		totalPage = totalPage <= 0 ? 1 : totalPage;
		currentPage = currentPage > totalPage ? totalPage : currentPage;
		List<TScheduling> list=schedulingService.selectTSchedulingList(organizationid,(currentPage - 1) * pageSize, pageSize);
		request.setAttribute("currentPage", currentPage);
        request.setAttribute("totalNum", totalNum);
        request.setAttribute("totalPage", totalPage);
		request.setAttribute("list", list);
		return "attendance/schedulingindex";
	}
	
	/**
	 * 生成排班日期信息
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException 
	 */
	@RequestMapping(value="/generateSchedulingByid",method=RequestMethod.GET)
	public String generateSchedulingByid(HttpServletRequest request, Model model) throws ParseException{
		String id = request.getParameter("id");
		long time=System.currentTimeMillis();
		int year=DateUtil.getYear(time);
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		List<TShift> list=shiftService.selectTShiftList(organizationid,0, 999);
		List<TSchedulingdetails>  tailist=schedulingdetailsService.getTSchedulingdetailsByYear(year, Integer.valueOf(id));
		String day="";
		int i=0;
		String colour=null;
		int shiid=0;
		boolean fal=false;
		for (TSchedulingdetails tai : tailist) {
			i++;
			for (TShift shift:list) {
				if(shift.getId()==tai.getShiftId()){
					colour=shift.getColour();
					shiid=shift.getId();
					fal=true;
				}
			}
			if(!fal){
				fal=false;
				colour="workday";
				shiid=0;
			}
			day+="'"+tai.getMonth()+"-"+tai.getDay()+"-"+colour+"-"+shiid+"'";
			if(i<tailist.size()){
				day+=",";
			}
		}
		request.setAttribute("scheid", id);
		request.setAttribute("day", day);
		request.setAttribute("list", list);
		return "attendance/insertscheduling";
	}
	
	/**
	 * 根据年份和班次id获取考勤信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="generateSchedulingYearByid",method = RequestMethod.GET)
	@ResponseBody
	public String generateSchedulingYearByid(HttpServletRequest request,Model model){
		String year = request.getParameter("year");
		String id = request.getParameter("id");
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		List<TShift> list=shiftService.selectTShiftList(organizationid,0, 999);
		List<TSchedulingdetails>  tailist=schedulingdetailsService.getTSchedulingdetailsByYear(Integer.valueOf(year), Integer.valueOf(id));
		Map<String, Object> map = new HashMap<>();
		String day="";
		int i=0;
		String colour=null;
		int shiid=0;
		boolean fal=false;
		for (TSchedulingdetails tai : tailist) {
			i++;
			for (TShift shift:list) {
				if(shift.getId()==tai.getShiftId()){
					colour=shift.getColour();
					shiid=shift.getId();
					fal=true;
				}
			}
			if(!fal){
				fal=false;
				colour="workday";
				shiid=0;
			}
			day+="'"+tai.getMonth()+"-"+tai.getDay()+"-"+colour+"-"+shiid+"'";
			if(i<tailist.size()){
				day+=",";
			}
		}
		map.put("data", day);
		JSONObject object = JSONObject.fromObject(map);
		return object.toString();
	}
	
	/**
	 * 新增排班信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/insertScheduling",method=RequestMethod.GET)
	public String insertScheduling(HttpServletRequest request, Model model){
		return "attendance/insertschedu";
	}
	
	/**
	 * 新增排班信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/insertSche",method=RequestMethod.POST)
	public String insertSche(HttpServletRequest request, Model model){
		long time=System.currentTimeMillis();
		String name = request.getParameter("name");
		String lon = request.getParameter("lon");
		String lat = request.getParameter("lat");
		if(lon==null||"".equals(lon)){
			lon="0";
		}
		if(lat==null||"".equals(lat)){
			lat="0";
		}
		int organizationid=(int) request.getSession().getAttribute("organizationid");
		TScheduling sche=new TScheduling();
		sche.setName(name);
		sche.setCreatetime(time);
		sche.setLat(Double.valueOf(lat));
		sche.setLon(Double.valueOf(lon));
		sche.setOrganizationId(organizationid);
		int fal=schedulingService.insertTScheduling(sche);
		if(fal>0){
			request.setAttribute("msg", "新增排班成功!");
		}else{
			request.setAttribute("msg", "新增排班失败!");
		}
		return "attendance/insertschedu";
	}
	
	/**
	 * 删除班次信息
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/deleteScheduling",method=RequestMethod.POST)
	public String deleteScheduling(HttpServletRequest request, Model model){
		String id = request.getParameter("id");
		List<Integer> clocks=new ArrayList<Integer>();
		if(id!=null&&id!=""){
			List<TSchedulingdetails> schelist=schedulingdetailsService.getTSchedulingdetailsByscheid(Integer.valueOf(id));
			if(schelist!=null&&schelist.size()>0){
				for (TSchedulingdetails sche : schelist) {
					for (TClocktime clo : sche.getClolist()) {
						clocks.add(clo.getDetailsId());
					}
				}
			}
			if(clocks!=null&&clocks.size()>0){
				clocktimeService.deleteTClocktimeList(clocks);
			}
			schedulingdetailsService.deleteTSchedulingdetailsByid(Integer.valueOf(id));
			schedulingService.deleteTScheduling(Integer.valueOf(id));
		}
		return index(request, model);
	}
}
